const OpenAI = require("openai");

require("dotenv").config();

const openai = new OpenAI({
  apiKey: process.env.DASHSCOPE_API_KEY,
  baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
});

/**
 * @param {string} base64Imge
 */
module.exports.recognizeImageContent = (base64Imge) => {
  return openai.chat.completions.create({
    model: "qwen-vl-max",
    messages: [
      {
        role: "user",
        content: [
          {
            type: "image_url",
            image_url: {
              url: `data:image/jpeg;base64,${base64Imge}`,
            },
          },
          { type: "text", text: "描述眼前的场景" },
        ],
      },
    ],
  });
};
